<?php
session_start();
include("../includes/conn.php");
$dbconn->admin_logincheck();
if($_GET['act']=='del'){
$id=intval($_GET['id']);
$dbconn->noretquery("delete from ".DBQIAN."exchangeuser where id=$id");
header("Location: hy.php?page=$_GET[page]");
};
$username = isset($_GET['username'])?$_GET['username']:'';
$name = isset($_GET['name'])?$_GET['name']:'';
$fwm = isset($_GET['fwm'])?$_GET['fwm']:'';
$begintime = isset($_GET['begintime'])?$_GET['begintime']:'';
$endtime = isset($_GET['endtime'])?$_GET['endtime']:'';
$where = '1';
if($username)
{
	$where .= ' and '.DBQIAN.'exchangeuser.username=\''.$username.'\'';
}
if($name)
{
	$where .= ' and '.DBQIAN.'exchangeuser.name=\''.$name.'\'';
}
if($fwm)
{
	$where .= ' and '.DBQIAN.'exchangeuser.fwm=\''.$fwm.'\'';
}
if ($begintime)
{
	$where .= ' and '.DBQIAN.'exchangeuser.time>=\''.$begintime.'\'';
}
if ($endtime)
{
	$where .= ' and '.DBQIAN.'exchangeuser.time<=\''.substr($endtime,0,10).' 23:59:59\'';
}
if ($_GET['act'] == 'trucate')
{
	$dbconn->noretquery("TRUNCATE TABLE ".DBQIAN."exchangeuser");
	header("Location: hyhb.php");
}
echo '<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<title>欢迎登录后台管理系统</title>
<link href="css/base.css" rel="stylesheet" type="text/css" />
<link href="css/right.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="css/jquery-ui.css" />
<script language="JavaScript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="js/jquery-ui-slide.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>
<script>
$(document).ready(function(){
   $(function(){
   		$(\'.time\').datetimepicker();
      $(\'.rightinfo tbody tr:odd\').css("backgroundColor","#f5f8fa");
   });
});
</script>
</head>

<body style="margin-top:0px;">
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li><a href="index.php">首页</a></li>
    <li>红包领取记录</li>
  </ul>
</div>
<div class="rightinfo">
  <div class="tools"> 
    <ul class="toolbar">
    	 <li style="background:#FFF; text-indent:1em; border:0;margin-bottom:10px;">
      <form name="fsoso" method="get" action="">
		手机号<input type="text" name="username" value="';echo $_GET['username'];;echo '" class="dfinput" style="width:150px" />
		<!--微信号<input type="text" name="wx_user" value="';echo $_GET['wx_user'];;echo '" class="dfinput" style="width:150px" />-->
		防伪码<input type="text" name="fwm" value="';echo $_GET['fwm'];;echo '" class="dfinput" style="width:150px" />
		开始时间 <input type="text" name="begintime"  value="';echo $_GET['begintime'];;echo '" placeholder="格式：2015-12-01" class="time dfinput" style="width:150px" />
		结束时间 <input type="text" name="endtime"  value="';echo $_GET['endtime'];;echo '" placeholder="格式：2015-12-01" class="time dfinput" style="width:150px" />
      <input name="submit" class="btn" value="查询" type="submit" >
      </form></li><br>
      <!--<li><a href="excel.hongbaolist.php"><span><img src="images/ico03.png" /></span>导出</a></li> -->
      <li><a href="excel.userhongbaolist.php?condition=';echo $where;;echo '"><span><img src="images/ico03.png" /></span>导出[按条件导出](最多65000条数据)</a></li>
      <li><a onClick="if(confirm(\'您确认要清空吗？\')){location.href=\'?act=trucate\'}" href="#"><span><img src="images/t03.png" /></span>清空记录</a></li>

    </ul>
  </div>
  <br/>
  <p style="height:15px;margin-bottom:10px;"></p>
  <table class="tablelist">
    <thead>
      <tr>
        <th width="10%">手机号</th>
        <!--<th width="6%">姓名</th>-->
        <!--<th width="4%">性别</th>-->
        <th width="9%">防伪码</th>
        <th width="8%">金额</th>
        <th width="12%">领取时间</th>
        <th width="15%">微信Openid</th>
        <th width="8%">操作</th>
      </tr>
    </thead>
    <tbody>
      ';
$page = ($_GET['page'] == ''||!isset($_GET['page'])) ?1:$_GET['page'];
$pagesize=12;
$num=$dbconn->countn(DBQIAN."exchangeuser",$where);
$pagelist = new page($page,$pagesize,$num ,10,2,0);
$query=$dbconn->news_list(" select * from ".DBQIAN."exchangeuser where ".$where." order by time desc ",$page,$pagesize);
while($row=$dbconn->fetch($query)){
//$urow=$dbconn->fetch($dbconn->query("select * from ".DBQIAN."users where username='$row[username]'"));
;echo '      <tr height="45">
		<td>';echo $row['username'];echo '</td>
       
        <td>';echo $row['fwm'];;echo '</td>
        <td>';echo $row['credit'].'元';;echo '</td>
         <td>';echo $row['time'];;echo '</td>
         <td>';echo $row['wx_user'];;echo '</td>
        <td>
          <img src="images/t03.png" width="14"> 
          <a onClick="if(confirm(\'您确认要删除吗？\')){window.location.href=\'?act=del&id=';echo $row['id'];echo '&page=';echo $page;echo '\'}" href="#" class="tablelink">删除</a>
        </td>
      </tr>
          ';
//if($row['xtype']==2){echo "奖励红包";};echo '        </td>
//       
//      ';
}
;echo '    </tbody>
  </table>
</div>
<div style=" width:90%; padding:10px 0 10px 0; text-align:center">
  ';if($num!=0) echo $pagelist->showpages();else echo "<font color='#ff0000'>暂无数据</font>";;echo '</div>
</body>
</html>'
?>